<?php

//convert single object to assosiative array
function objectArray( $object ) {
    if ( is_array( $object ))
        return $object ;
        
    if ( !is_object( $object ))
        return false ;
        
    $serial = serialize( $object ) ;
    $serial = preg_replace( '/O:\d+:".+?"/' ,'a' , $serial ) ;
    if( preg_match_all( '/s:\d+:"\\0.+?\\0(.+?)"/' , $serial, $ms, PREG_SET_ORDER )) {
        foreach( $ms as $m ) {
            $serial = str_replace( $m[0], 's:'. strlen( $m[1] ) . ':"'.$m[1] . '"', $serial ) ;
        }
    }    
    return @unserialize( $serial ) ;

}

//convert array of object to array
function arrayOfObjectToArray($var) {
    $result = array();    
    foreach ($var as $key => $value) {        
        if (is_object($value) || is_array($value)) {            
            $result[$key] = objectArray($value);           
        } else {            
            $result[$key] = $value;
        }
    }
    return $result;
}



?>
